package kaist.sep521.lego.circlebicycle;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class ManualActivity extends Activity {
	private WebView mWebView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_manual);
		mWebView = (WebView) findViewById(R.id.manual_webview);

		Intent intent = getIntent();
		String url = intent.getExtras().getString("url").toString();
		
		mWebView.getSettings().setJavaScriptEnabled(true); 
		mWebView.loadUrl(url);
		mWebView.setWebViewClient(new WebViewClientClass());
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) { 
		if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) { 
			mWebView.goBack(); 
			return true; 
		} 
		return super.onKeyDown(keyCode, event);
	}

	private class WebViewClientClass extends WebViewClient { 
		@Override
		public boolean shouldOverrideUrlLoading(WebView view, String url) { 
			view.loadUrl(url); 
			return true; 
		} 
	}
}
